#include <iostream>
#include "opencv2/opencv.hpp"
#include <ctime>
#include <cstdio>
#include <cstdlib>

#define MAIN_WINDOW "实时人脸识别系统"
#define PICTURE_PATH "./labixiaoxin.jpg"

using namespace std;
using namespace cv;

int main()
{
	VideoCapture camera(0);
	Mat img, picture_grey, roi;
	Mat picture = imread(PICTURE_PATH);
	int key;
	
	cvtColor(picture, picture_grey, COLOR_BGR2GRAY);

	threshold(picture_grey, picture_grey, 250, 255, THRESH_BINARY_INV);

	imshow("test", picture_grey);

	while(1)
	{
		if(!camera.read(img))
		{
			cerr << "摄像头打开失败" << endl;
			return 1;
		}

		roi = img(Rect(300, 100, picture.cols, picture.rows));
		picture.copyTo(roi, picture_grey);

		imshow(MAIN_WINDOW, img);	//显示图像 参数1：窗口名 参数2：图像对象

		key = waitKey(1);
		
		if(key == 'q')
			break;
		
	}

	return 0;
}